package com.hzjh.h5mall.ui.forgot

import android.graphics.Paint
import com.alibaba.android.arouter.facade.annotation.Route
import com.hzjh.base.ext.R
import com.hzjh.base.ext.frame.JHBaseActivity
import com.hzjh.base.ext.route.RouteUrl
import com.hzjh.base.router.ext.navigationTo
import com.hzjh.base.style.weight.ToastKt.toastCenter
import com.hzjh.base.utils.function.isEmail
import com.hzjh.base.utils.other.CommUtils
import com.hzjh.h5mall.databinding.ActivityForgotStep1Binding
import com.hzjh.h5mall.model.forgot.ForgotVM

@Route(path = RouteUrl.FORGOT_STEP1_ACTIVITY)
class ForgotStep1Activity : JHBaseActivity<ActivityForgotStep1Binding,ForgotVM>() {
    override fun initData() {

    }

    override fun initView() {
        viewBinding.btnNextStep.apply {
            paint.flags = Paint.UNDERLINE_TEXT_FLAG; //下划线
            paint.isAntiAlias = true;//抗锯齿
            setOnClickListener {
                val email = viewBinding.inputEmail.text.toString()
                if(!email.isEmail()){
                    toastCenter(CommUtils.getString(R.string.jh_email_check_toast))
                    return@setOnClickListener
                }
                navigationTo(RouteUrl.FORGOT_STEP2_ACTIVITY){
                    withString(RouteUrl.PARAMS_EMAIL,email)
                }
            }
        }
        viewBinding.inputEmail.setTextChangeListener {
            viewBinding.btnNextStep.isEnabled=!it.isNullOrBlank()
        }
    }

    override fun initViewBinding(): ActivityForgotStep1Binding {
        return ActivityForgotStep1Binding.inflate(layoutInflater)
    }
}